//
//  SelectedTypeCell.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/9/5.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class SelectedTypeCell: UITableViewCell {
    
    let titleLabel = UILabel()
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.contentView.backgroundColor = UIColor.white
        
        let imageView = UIImageView()
        imageView.image = UIImage.imageWithName("bksq_avatar")
        self.contentView.addSubview(imageView)
        
        let redView = UIView()
        redView.layer.contents = UIImage.imageWithName("bksq_bg").cgImage
        self.contentView.addSubview(redView)
        
        titleLabel.textColor = UIColor.white
        titleLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 14))
        redView.addSubview(titleLabel)
        
        imageView.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(RATIO(maxNum: -8))
            make.centerY.equalToSuperview()
            make.width.height.equalTo(RATIO_H(maxNum: 40))
            
        }
        
        redView.snp.makeConstraints { (make) in
            make.right.equalTo(imageView.snp.left).offset(RATIO(maxNum: -8))
            make.centerY.equalTo(imageView)
            make.width.equalTo(RATIO(maxNum: 150))
            make.height.equalTo(RATIO_H(maxNum: 30))
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.centerX.equalTo(redView.snp.centerX).offset(RATIO(maxNum: -10))
            make.width.greaterThanOrEqualTo(10)
            make.height.greaterThanOrEqualTo(10)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
